VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestStringDifference"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private mDiff As VBUnit2.StringDifference
Private mMessage As New StringMessage

Public Sub testEmptyStrings()
templateTest "", ""
End Sub

Public Sub testSingleCharSame()
templateTest "s", "s"
End Sub
Public Sub testSingleCharStringsDifferent()
templateTest "a", "b"
End Sub
Public Sub testMultiCharSameShort()
templateTest "samestring", "samestring"
End Sub
Public Sub testMultiCharSameLong()
givenStringDifference 9
whenComparing "samestring", "samestring"
thenResultIs True
thenMessageIs "<samest...> is the same as <samest...>"
End Sub

Public Sub testMultiCharStringsDifferentShort()
templateTest "different1", "different2"
End Sub
Public Sub testMultiCharStringsDifferentLong1()
givenStringDifference 9
whenComparing "different1", "different2"
thenResultIs False
thenMessageIs "Expected: <different1>" & vbCrLf + _
                "but got:  <different2>" & vbCrLf + _
                "First difference:   ^" & vbCrLf + _
                "index 10 -----------|"
End Sub
Public Sub testMultiCharStringsDifferentLong2()
givenStringDifference 9
whenComparing "differentlonger1", "differentlonger2"
thenResultIs False
thenMessageIs "Expected: <differentlonger1>" & vbCrLf + _
                "but got:  <differentlonger2>" & vbCrLf + _
                "First difference:         ^" & vbCrLf + _
                "index 16 -----------------|"
End Sub
Public Sub testMultiCharStringsDifferentLong3()
Dim LHS As String
Dim RHS As String
LHS = String(100, "=")
RHS = LHS
Mid(RHS, 70, 1) = "+"
givenStringDifference 9
whenComparing LHS, RHS
thenResultIs False
'                         1234567890123456789012345678901234567890123456789012345678901234567890
thenMessageIs "Expected: <...============================================...>" & vbCrLf + _
              "but got:  <...===========================================+...>" & vbCrLf + _
              "First difference:                                        ^" & vbCrLf + _
              "index 70 ------------------------------------------------|"
End Sub


''
Private Sub templateTest(LHS As String, RHS As String)
Dim result As Boolean
result = (LHS = RHS)

givenStringDifference
whenComparing LHS, RHS
thenResultIs result
thenMessageIs templateMessage(result, LHS, RHS)
'''thenMessageIs mMessage.message(result, LHS, RHS)
End Sub
Private Function templateMessage(result As Boolean, LHS As String, RHS As String) As String
If result Then
    templateMessage = "<" + LHS + ">" + " is the same as " + "<" + RHS + ">"
Else
    templateMessage = "<" + LHS + ">" + " is not the same as " + "<" + RHS + ">"
End If
End Function

Private Sub givenStringDifference(Optional maxLength As Integer = 12)
Set mDiff = New VBUnit2.StringDifference
'init with params
mDiff.init maxLength
End Sub

Private Sub whenComparing(LHS As String, RHS As String)
mDiff.compare LHS, RHS
End Sub

Private Sub thenResultIs(result As Boolean)
assert.equals mDiff.result, result, "Result should be: " + CStr(result)
End Sub
Private Sub thenMessageIs(message As String)
assert.equals mDiff.message, message, "Message should be: '" + message + "'"
End Sub


'OPTIONAL METHODS
'Public Sub setup()
''
'End Sub
Public Sub teardown()
Set mDiff = Nothing
End Sub
Public Function NumOfAsserts() As Long
NumOfAsserts = 18
End Function

'Private Sub Class_Initialize()
''
'End Sub
'Private Sub Class_Terminate()
''
'End Sub
